<template>
    <van-popup v-model="showPop" position="bottom">
        <datetime-picker v-model="selectDate" type="date" title="选择年月日" :min-date="minDate" :max-date="maxDate" @cancel="showPop=false" @confirm="confirm" />
    </van-popup>
</template>

<script>

import { DatetimePicker } from 'vant';
import dayjs from 'dayjs'

export default {

    props: {
        minDate: {
            type: Date,
            default: () => new Date(2000, 0, 1),
        },

        maxDate: {
            type: Date,
            default: () => new Date(2050, 0, 1),
        }
    },

    components: { DatetimePicker },

    data() {
        return {
            showPop: false,
            selectDate: ""
        }
    },

    methods: {
        show() {
            this.showPop = true;
        },

        confirm(e) {
            let dateStr = dayjs(e).format('YYYY-MM-DD')
            this.$emit("commit", dateStr);
            this.showPop = false;
        },
    }

}

</script>

<style>
</style>